package gui;

import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;
import java.awt.Color;
import java.awt.Component;
 
public class ColorTableCellRenderer extends JLabel implements TableCellRenderer {
	private static final long serialVersionUID = 8120510779104733230L;

	public ColorTableCellRenderer() {
		super();
        setOpaque(true); //MUST do this for background to show up.
    }
 
    public Component getTableCellRendererComponent(JTable table, Object color, boolean isSelected, boolean hasFocus, int row, int column) {
        Color newColor = (Color)color;
        setBackground(newColor);
        setToolTipText("RGB value: " + newColor.getRed() + ", "
                                     + newColor.getGreen() + ", "
                                     + newColor.getBlue());
        return this;
    }
}